<?php

namespace App\Console\Commands;

use App\Models\ApiLogModel;
use App\Models\ManageCMDModel;
use App\Models\RecordBunkoModel;
use App\Models\RecordFlyModel;
use App\Models\RecordFriendKillModel;
use App\Models\RecordKillModel;
use App\Models\RecordPlayerModel;
use App\Models\RecordTalkModel;
use App\Models\RecordTeamModel;
use Illuminate\Console\Command;

class AutoCleanCmd extends Command{

    public $signature = 'db:auto-clean';

    public function handle()
    {
        RecordFlyModel::where('created_at', '<', date('Y-m-d H:i:s', strtotime('-3 month')))->delete();

        RecordKillModel::where('created_at', '<', date('Y-m-d H:i:s', strtotime('-1 month')))->delete();

        RecordTeamModel::where('created_at', '<', date('Y-m-d H:i:s', strtotime('-3 month')))->delete();
        RecordBunkoModel::where('created_at', '<', date('Y-m-d H:i:s', strtotime('-3 month')))->delete();
        RecordTalkModel::where('created_at', '<', date('Y-m-d H:i:s', strtotime('-3 month')))->delete();
        RecordFriendKillModel::where('created_at', '<', date('Y-m-d H:i:s', strtotime('-3 month')))->delete();

        RecordPlayerModel::where('created_at', '<', date('Y-m-d H:i:s', strtotime('-3 month')))->delete();

        ManageCMDModel::where('created_at', '<', date('Y-m-d H:i:s', strtotime('-3 month')))->delete();


        ApiLogModel::where('created_at', '<', date('Y-m-d H:i:s', strtotime('-3 month')))->delete();
        ApiLogModel::where('path','/api/system/add')->where('created_at', '<', date('Y-m-d H:i:s', strtotime('-1 day')))->delete();
        ApiLogModel::where('path','/api/record/get')->where('created_at', '<', date('Y-m-d H:i:s', strtotime('-1 day')))->delete();
    }
}


